package com.quarter.dao.impl;

import java.sql.*;
import java.util.*;
import com.quarter.db.*;
import com.quarter.dao.StudentListDao;
import com.quarter.vo.User;

public class StudentListDaoImpl implements StudentListDao{		
	public ArrayList<User> ListAllStudentsID() throws Exception{	
		ArrayList<User> list = new ArrayList<User>();
        String sql="SELECT * FROM student";
        Connection conn=null;
        PreparedStatement preStmt=null;
        ResultSet rs=null;
        try{
            conn=DBConnect.getCon();
            preStmt=conn.prepareStatement(sql);
            rs=preStmt.executeQuery();
            while(rs.next()){
            	User user =new User();
            	user.setUid(rs.getString("SID"));
            	user.setName(rs.getString("SNAME"));
            	user.setMail(rs.getString("MAIL"));
            	list.add(user);
            	//System.out.println(user.getName());
            }
        }finally{
            if(rs!=null) rs.close();
            if(preStmt!=null) preStmt.close();
            if(conn!=null)  conn.close();
        }
        
        return list;
	}
	
}
